<p>
  <b>Hospede:</b>
  <%=h @conta.hospede.nome %>

<table>
  <tr> 
    <th>Serviço</th>
    <th colspan="">Opções</th>
  </tr>

<% par_impar = 0;
  for aluguel in @alugueis 
	  par_impar = 1 - par_impar %>
  <tr class="listLine<%= par_impar %>">
    <td><%=h aluguel.servico.nome %></td>
    <td width="5%"><%= link_to 'Exibir', aluguel %></td>
    <td width="5%"><%= link_to 'Remover', aluguel, :confirm => 'Você tem certeza?', :method => :delete %></td>
  </tr>
<% end %>
		
	<tr class="listLine<%= 1 - par_impar %>"> <td colspan="3">Valor total dos alugueis: 
		<% total_aluguel = 0
		for aluguel in @alugueis 
		valor_aluguel = Servico.find(:last, :conditions => ["id = ?", aluguel.servico_id]).valor	
		total_aluguel = total_aluguel + valor_aluguel
		%>
		<%end%>
		<b><%= total_aluguel %></b> 
		reais.</td></tr>

	<tr class="listLine<%= par_impar %>"><td colspan="3">Valor total de diarias: 
		<% total_diaria = 0
		for apt in @apts
		tipo = Apartamento.find(:last, :conditions => ["id = ?", apt.apartamento_id]).tiposApartamento_id
		valor_diaria = TiposApartamento.find(:last, :conditions => ["id = ?",tipo]).valor
		dias = Date.today - @conta.dataEntr.to_date+1
		total_diaria = total_diaria + valor_diaria*dias
		%>
		<%end%>
		<b><%= total_diaria %></b> 
		reais.</td></tr>

		
	<tr class="listLine<%= 1 - par_impar %>"><td colspan="3">Valor total a pagar:
		<b><%= total_diaria+total_aluguel %></b> reais.</td></tr>
	</td>	
		
		
</table>

<p>
	<%
		if @conta.encerrada
	%>
	<%= link_to 'Pagar', :action => "pagar", :id => @conta.id %>
	<%
		else
	%>
	<%= link_to 'Encerrar', :action => "encerrar", :id => @conta.id %>
	<%
		end
	%>
</p>
<%= link_to 'Voltar', :controller => "apartamentos", :action => "show", :id => ContasApartamento.find(:last, :conditions => ["conta_id = ?", @conta.id] ).apartamento_id %>
